package net.blueleek.singleton;

/**
 * 双重检查锁定 <br>
 * 不适用于1.4及更早版本的Java
 * 
 * @author lianxh
 * @date 2013-5-21 上午12:31:42
 */
public class DoubleCheckedLockingSingleton {

	private static volatile DoubleCheckedLockingSingleton INSTANCE;

	private DoubleCheckedLockingSingleton() {
		// do nothing
	}

	public static DoubleCheckedLockingSingleton getInstance() {
		if (null == INSTANCE) {
			synchronized (DoubleCheckedLockingSingleton.class) {
				if (null == INSTANCE) {
					INSTANCE = new DoubleCheckedLockingSingleton();
				}
			}
		}
		return INSTANCE;
	}

	/**
	 * 实例提供的方法
	 */
	public void doSomething() {
		// do something
	}
}
